//
//  SingleCheckCell.m
//  CheckDemo
//
//  Created by Allison on 2023/11/11.
//

#import "SingleCheckCell.h"
#import "Masonry.h"

@interface SingleCheckCell()
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *checkImageView;
@property (nonatomic, strong) UIView *lineView;
@end


@implementation SingleCheckCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(15 );
        make.left.equalTo(self.contentView).offset(20);
        make.width.and.height.mas_equalTo(45 );
    }];

    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView.mas_bottom).offset(5 );
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.right.equalTo(self.contentView.mas_right).offset(15);
        make.height.mas_equalTo(15 );
    }];

    [self.contentView addSubview:self.checkImageView];
    [self.checkImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        //make.top.equalTo(self.contentView).offset(15 );
        make.width.and.height.mas_equalTo(20);
        make.right.equalTo(self.contentView).offset(-15);
        make.centerY.equalTo(self.contentView);
    }];
    
    [self.contentView addSubview:self.lineView];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-2);
        make.height.mas_equalTo(1);
        make.left.and.right.equalTo(self.contentView);
    }];
}

- (void)setMenuModel:(MenuModel *)menuModel {
    self.titleLabel.text = menuModel.title;
    self.checkImageView.image = [UIImage imageNamed:menuModel.isSelect == YES ? @"hx_compose_guide_check_box_selected" : @"hx_compose_guide_check_box_default"];
}


- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        UIImageView *temp = [[UIImageView alloc] init];
        temp.backgroundColor = [UIColor clearColor];
        temp.image = [UIImage imageNamed:@"login_electronicTokenLost"];
        temp.userInteractionEnabled = YES;
        _iconImageView = temp;
    }
    return _iconImageView;
}


- (UILabel *)titleLabel {
    if (!_titleLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.textAlignment = NSTextAlignmentLeft;
        //label.text = @"测试标题";
        label.textColor = [UIColor blackColor];
        label.font = [UIFont systemFontOfSize:15.0];
        label.backgroundColor = [UIColor clearColor];
        _titleLabel = label;
    }
    return _titleLabel;
}


- (UIImageView *)checkImageView {
    if (!_checkImageView) {
        UIImageView *img = [[UIImageView alloc]init];
        img.backgroundColor = [UIColor clearColor];
        _checkImageView = img;
    }
    return _checkImageView;
}

- (UIView *)lineView {
    if (!_lineView) {
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor grayColor];
        _lineView = view;
    }
    return _lineView;
}

@end
